package com.demo.client;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.demo.client.OneClient.HystrixClientFallback;

@FeignClient(value = "service-two", fallback = HystrixClientFallback.class)
public interface OneClient {
	@RequestMapping(method = RequestMethod.GET, value = "/hi")
	String getFromTwo(@RequestParam(value = "name") String name) throws Exception;

	@Component
	static class HystrixClientFallback implements OneClient {

		@Override
		public String getFromTwo(String name) throws Exception {
			throw new Exception("出异常了,可能是请求超时！参数 name:"+name);
		}

	}
}
